// 巡察中心 相关的api接口

import service from '@/utils/request'
import constant from '@/utils/constant'
import Qs from 'qs'

const root = (process.env.NODE_ENV === 'development' ? '/api' : '')

// ===============================================================
// 截图上传,(支持多图片上传)
export function uploadScreenshot(data) {
  return service({
    url: root + constant.upload_screenshot,
    method: 'post',
    data: Qs.stringify(data)
  })
}
// 提交巡检记录
export function submitInspection(data) {
  return service({
    url: root + constant.submit_inspection,
    method: 'post',
    data
  })
}
// 查询巡检记录
export function listInspection(params) {
  return service({
    url: root + constant.list_cruising,
    method: 'get',
    params: params
  })
}
// 查询巡检记录2
export function listInspection2(data) {
  return service({
    url: root + constant.list_cruising2,
    method: 'get',
    params: {
      recordIds: data
    },
    paramsSerializer: params => {
      return Qs.stringify(params, {arrayFormat: 'repeat'})
    }
  })
}

export function listInspection3(data) {
  return service({
    url: root + constant.list_cruising2,
    method: 'get',
    params: data
  })
}

// 巡察分析看板
export function detailInspection() {
  return service({
    url: root + constant.detail_inspection,
    method: 'get'
  })
}
// base64图片上传(支持单个)
export function uploadScreenshot64(data) {
  return service({
    url: root + constant.upload_screenshot64,
    method: 'post',
    data
  })
}

// 添加考评组
export function addCheck(data) {
  return service({
    url: root + constant.add_check,
    method: 'post',
    data
  })
}
// 修改考评组
export function editCheck(data) {
  return service({
    url: root + constant.edit_check,
    method: 'post',
    data
  })
}
// 删除考评组
export function delCheck(data) {
  return service({
    url: root + constant.del_check,
    method: 'post',
    // data: Qs.stringify(data),
    // params: data
    data
  })
}
// 考评组列表
export function listCheck(params) {
  return service({
    url: root + constant.list_check,
    method: 'get',
    params: params
  })
}

// 添加考评模板
export function addTemplate(data) {
  return service({
    url: root + constant.add_template,
    method: 'post',
    data
  })
}
// 修改考评模板
export function editTemplate(data) {
  return service({
    url: root + constant.edit_template,
    method: 'post',
    data
  })
}
// 删除考评模板
export function delTemplate(data) {
  return service({
    url: root + constant.del_template,
    method: 'post',
    data
  })
}
// 模板列表
export function listTemplate(params) {
  return service({
    url: root + constant.list_template,
    method: 'get',
    params: params
  })
}

// 添加规则
export function addRegular(data) {
  return service({
    url: root + constant.add_regular,
    method: 'post',
    data
  })
}
// 删除规则
export function delRegular(data) {
  return service({
    url: root + constant.del_regular,
    method: 'post',
    data
  })
}
// 修改规则
export function editRegular(data) {
  return service({
    url: root + constant.edit_regular,
    method: 'post',
    data
  })
}
// 规则列表
export function listRegular(params) {
  return service({
    url: root + constant.list_regular,
    method: 'get',
    params: params
  })
}

// 巡察记录-------------------
export function listCruising(params) {
  return service({
    url: root + constant.list_cruising,
    method: 'get',
    params: params
  })
}
// 下拉回显,选择巡察网点
export function cruisingBranch(params) {
  return service({
    url: root + constant.cruising_branch,
    method: 'get',
    params: params
  })
}
// 下拉回显,选择发起人
export function cruisingInitiator(params) {
  return service({
    url: root + constant.cruising_initiator,
    method: 'get',
    params: params
  })
}
// 下拉回显,选择巡店人
export function cruisingUser(params) {
  return service({
    url: root + constant.cruising_user,
    method: 'get',
    params: params
  })
}

// 任务巡查-----------------------------
// 1.查询评检组以及评检项

// 1.查询当前用户的下级用户
export function getLowerUserofCurrentUser(params) {
  return service({
    url: root + constant.getLowerUserofCurrentUser,
    method: 'get',
    params: params
  })
}

// 2.删除巡检任务
export function removePatrolTask(params) {
  return service({
    url: root + constant.removePatrolTask,
    method: 'delete',
    params: params
  })
}

// 3.查询定时任务列表
export function listPatrolTask(params) {
  return service({
    url: root + constant.listPatrolTask,
    method: 'get',
    params: params
  })
}

// 4.查询巡店任务网点
export function listPatrolTaskPoint(params) {
  return service({
    url: root + constant.listPatrolTaskPoint,
    method: 'get',
    params: params
  })
}

// 5.查询巡检任务发起人信息
export function listSendUsers(params) {
  return service({
    url: root + constant.listSendUsers,
    method: 'get',
    params: params
  })
}

// 6.任务巡店人
export function listPatrolUsers(params) {
  return service({
    url: root + constant.listPatrolUsers,
    method: 'get',
    params: params
  })
}

// 7.查询逾期状态列表
export function listOverdue(params) {
  return service({
    url: root + constant.listOverdue,
    method: 'get',
    params: params
  })
}


// 8.查询评检组以及评检项
export function getCheckGroupAndItem(params) {
  return service({
    url: root + constant.getCheckGroupAndItem,
    method: 'get',
    params: params
  })
}

// (详情)查询巡检记录基本信息
export function getRecordBase(params) {
  return service({
    url: root + constant.record_base_info,
    method: 'get',
    params: params
  })
}

// (详情)查询巡检记录分数信息
export function getRecordScore(params) {
  return service({
    url: root + constant.record_score_info,
    method: 'get',
    params: params
  })
}

// (详情)查询巡检记录结果统计
export function getRecordResult(params) {
  return service({
    url: root + constant.record_result_info,
    method: 'get',
    params: params
  })
}

// (详情)查询巡检问题列表
export function getRecordIssue(params) {
  return service({
    url: root + constant.record_issue_info,
    method: 'get',
    params: params
  })
}

// 查询巡检问题工单列表
export function queryWorkOrderIssueList(data) {
  return service({
    url: root + constant.work_order_issue_list,
    method: 'post',
    data
  })
}

// 提交巡检工单-new
export function submitPatrolWorkOrder2(data) {
  return service({
    url: root + constant.patrol_work_order2,
    method: 'post',
    data
  })
}

// ========巡查分析===========
// 查询当前用户网点
export const queryCurrUserSite = (params) => {
  return service({
    url: root + constant.currUserSite,
    method: 'get',
    params: params
  })
}
// 查询巡检网点总数
export const querySiteTotal = (params) => {
  return service({
    url: root + constant.siteTotal,
    method: 'get',
    params: params
  })
}
// 获取本期巡店数、环比、巡检合格率
export const queryPatrolSiteTotal = (params) => {
  return service({
    url: root + constant.patrolSiteTotal,
    method: 'get',
    params: params
  })
}
// 获取得分率分布
export const queryRatioScore = (params) => {
  return service({
    url: root + constant.ratioScore,
    method: 'get',
    params: params
  })
}
// 获取门店问题量排名
export const queryIssueRanking = (params) => {
  return service({
    url: root + constant.issueRanking,
    method: 'get',
    params: params
  })
}
// 获取门店合格率
export const querySiteQualifyRatio = (params) => {
  return service({
    url: root + constant.siteQualifyRatio,
    method: 'get',
    params: params
  })
}
// 督导执行力-巡店覆盖情况
export const queryPatrolCoverage = (params) => {
  return service({
    url: root + constant.patrolCoverage,
    method: 'get',
    params: params
  })
}
// 督导执行力-任务巡店逾期情况
export const queryPatrolTask = (params) => {
  return service({
    url: root + constant.patrolTask,
    method: 'get',
    params: params
  })
}

// 获取人员检测分页数据
// GET /kd-server/detection/getPage
// 接口ID：16143688
// 接口地址：https://www.apifox.cn/web/project/457725/apis/api-16143688
export const getDetectionList = (params) => {
  return service({
    url: root + constant.person_detection_list,
    method: 'get',
    params: params
  })
}
